/******/ (() => { // webpackBootstrap
/******/ 	"use strict";
/******/ 	var __webpack_modules__ = ({

/***/ "./src/Setting.ts":
/*!************************!*\
  !*** ./src/Setting.ts ***!
  \************************/
/***/ ((__unused_webpack_module, exports, __webpack_require__) => {


Object.defineProperty(exports, "__esModule", ({ value: true }));
exports.Setting = void 0;
var FairyEditor = CS.FairyEditor;
const Util_1 = __webpack_require__(/*! ./Util */ "./src/Util.ts");
const fs = CS.System.IO.File;
const director = CS.System.IO.Directory;
const Path = CS.System.IO.Path;
class Setting {
    /**资源目录路径*/ assetsPath;
    /**UI配置目录路径*/ uiJsonPath;
    /**UI代码目录路径*/ layoutPath;
    /**布局代码模板路径*/ layoutTemplatePath;
    /**项目名称*/ projName;
    defaultCls;
    constructor() {
        const App = FairyEditor.App;
        let s = this;
        let publishPath;
        publishPath = Path.Combine(App.project.settingsPath, "GYPublish.json");
        s.projName = Path.GetFileName(Util_1.Util.getParentDirectory(App.project.basePath));
        s.assetsPath = Util_1.Util.getParentDirectory(App.project.basePath);
        s.uiJsonPath = Path.GetFullPath("uiJson", s.assetsPath);
        s.layoutPath = Path.GetFullPath("src/gameModule/" + s.projName + "/ts/UI/layout", Util_1.Util.getParentDirectory(s.assetsPath, 2));
        s.layoutTemplatePath = Path.Combine(App.project.settingsPath, "layout.ts-template");
        s.defaultCls = "GYLite.GYUIComponent";
        if (!fs.Exists(s.layoutTemplatePath)) {
            fs.WriteAllText(s.layoutTemplatePath, Setting.defaultLayoutTemp.replace("{TEMP_PATH}", s.layoutTemplatePath));
            console.log("不存在布局ts模板文件，自动创建!" + s.layoutTemplatePath);
        }
        if (!fs.Exists(publishPath)) {
            let defaultSetting = {
                assetPath: s.assetsPath,
                uiJsonPath: s.uiJsonPath,
                layoutPath: s.layoutPath,
                layoutTemplatePath: s.layoutTemplatePath,
                defaultCls: s.defaultCls,
                projName: s.projName
            };
            console.log("羔羊发布配置创建成功!" + publishPath);
            fs.WriteAllText(publishPath, JSON.stringify(defaultSetting, null, 4));
        }
        else
            console.log("存在羔羊发布配置!" + publishPath);
        //ui布局目录，没有则创建
        if (!director.Exists(s.uiJsonPath))
            director.CreateDirectory(s.uiJsonPath);
        //创建失败
        if (!director.Exists(s.uiJsonPath))
            console.error("插件无法使用，uiJson目录不存在！" + s.uiJsonPath);
        //ui布局代码目录，没有则创建
        if (!director.Exists(s.layoutPath))
            director.CreateDirectory(s.layoutPath);
        //创建失败
        if (!director.Exists(s.layoutPath))
            console.error("插件无法使用，资源目录不存在！" + s.layoutPath);
    }
    getLayoutTS() {
        let s = this;
        return fs.ReadAllText(s.layoutTemplatePath);
    }
    /**模板字符串
     * {TEMP_PATH} 模板文件路径
     * {MODULE} 模块名称
     * {COMPONENT} 组件名称
     * {PACKAGE} 包名称
     * {PROPERTY} ts属性定义
    */
    static defaultLayoutTemp = `/**通过模板文件(G:\\羔羊框架\\2022最新工具引擎\\Git\\miniGames\\game_04\\assets\\allGame\\FGUIProject\\settings\\layout.ts-template)自动生成*/
module {MODULE}
{
    export class {COMPONENT}Layout
    {
        /**布局UI
         * @param xmlParser 配置解析器，请使用布局配置所属的winID获取
         * @param parent 布局的父级
         * @param justChidren 是否只布局子级内容，默认true，false则会创建组件容器
        */
        public static layout(xmlParser:edc.XMLParser, parent:GYLite.GYUIComponent, justChidren:boolean=true):GYLite.GYUIComponent
        {
            if(!xmlParser)return;
            let data:edc.IXMLData = xmlParser.getXMLData("{COMPONENT}.xml", "{PACKAGE}.json");
            if(justChidren)
            {
                xmlParser.instantiateChilds(data, parent, data);
                return null;
            }                
            return xmlParser.instantiate(data, parent);
        }
        
    }    
    export interface I{COMPONENT}
    {//{PROPERTY}		        
        [key:string]:any;
    } 
}`;
}
exports.Setting = Setting;


/***/ }),

/***/ "./src/Util.ts":
/*!*********************!*\
  !*** ./src/Util.ts ***!
  \*********************/
/***/ ((__unused_webpack_module, exports, __webpack_require__) => {


Object.defineProperty(exports, "__esModule", ({ value: true }));
exports.Util = void 0;
const XMLConfig_1 = __webpack_require__(/*! ./xmlUIParse/XMLConfig */ "./src/xmlUIParse/XMLConfig.ts");
const Path = CS.System.IO.Path;
class Util {
    static packageDict;
    static referencePkgs;
    static exportedList;
    static packInit() {
        Util.packageDict = {};
        Util.referencePkgs = [];
        Util.exportedList = [];
    }
    /**使用示例：获取上两级目录
    *   string result = getParentDirectory("Assets/A/B/C/file.txt", 2);
    *   结果: "Assets/A/B"
    **/
    static getParentDirectory(path, levels = 1) {
        for (let i = 0; i < levels; i++) {
            path = Path.GetDirectoryName(path);
            if (path == null || path == "")
                break;
        }
        return path;
    }
    static getFileName(path) {
        let arr = path.split("/");
        let n;
        n = arr.pop();
        return n.split(".")[0];
    }
    /**是否需要导出代码(注意要确保packageDict字典已获得所有关联包，否则外部包描述获取不了则无法正确判定是否属于需要导出的数据)*/
    static isExported(xmlData, packageData) {
        let descXMLData;
        descXMLData = Util.findDescXMLData(xmlData, packageData);
        if (descXMLData && descXMLData.attrs.exported) //需要导出代码
            return true;
        return false;
    }
    /**查询节点的描述对象*/
    static findDescObj(xmlData) {
        return Util.packageDict[xmlData.attrs.pkg];
    }
    /**查询节点的描述*/
    static findDescXMLData(xmlData, packageData) {
        let len;
        let descXMLDatas;
        packageData = xmlData.attrs.pkg ? Util.packageDict[xmlData.attrs.pkg].packageData : packageData;
        descXMLDatas = packageData.childs[0].childs;
        len = descXMLDatas.length;
        while (--len > -1) {
            if (xmlData.fileName == descXMLDatas[len].attrs.name || xmlData.attrs.src == descXMLDatas[len].attrs.id)
                return descXMLDatas[len];
        }
        return null;
    }
    /**获取数据节点的类路径(注意要确保packageDict字典已获得所有关联包，否则外部包描述获取不了则无法得到正确的类路径)*/
    static getClassPath(xmlData, packageData) {
        let descXMLData = Util.findDescXMLData(xmlData, packageData);
        if (descXMLData)
            return descXMLData.attrs.path.substr(1) + descXMLData.attrs.name.split(".")[0];
        return null;
    }
    /**获取定义类名
     * @param xmlData 节点数据
     * @param extentionXMLData 扩展数据
     * @param parser 解析器
     * @param descXMLDatas 描述列表数据
     * @param pkgName 包名
     * @param defaultCls 默认类名
    */
    static getDefClass(xmlData, extentionXMLData, parser, packageData, pkgName, defaultCls) {
        let cls;
        let descXMLData;
        if (extentionXMLData) {
            let ex = extentionXMLData.attrs.extention;
            if (ex == "Button") //按钮有3种模式，特殊处理一下类型
             {
                let mode;
                let attriDef = XMLConfig_1.XMLConfig.getAttrDef(extentionXMLData.tagName, "mode");
                let result = parser.getTags(extentionXMLData, ["Button"]);
                if (result[0]) {
                    mode = result[0].attrs.mode | 0;
                    cls = attriDef.cls[mode];
                }
                else
                    mode = 0;
                cls = attriDef.cls[mode];
            }
            else if (ex == null || ex == "Label") {
                if (Util.isExported(xmlData, packageData)) {
                    let clsPath = Util.getClassPath(xmlData, packageData);
                    cls = pkgName + ".I" + clsPath; //自定义组件
                }
            }
            else {
                let tagDef = XMLConfig_1.XMLConfig.tag[ex];
                if (tagDef) {
                    if (ex == "ScrollBar") //滚动条有两种，根据形状判断
                     {
                        let isHorizonal;
                        isHorizonal = extentionXMLData.attrs.width > extentionXMLData.attrs.height;
                        cls = tagDef.clsEnum[isHorizonal ? 1 : 0];
                    }
                    else
                        cls = tagDef.cls; //使用扩展名
                }
            }
        }
        if (cls == null) {
            if (xmlData.tagName == "list") //列表分5种布局，所以有5个类
             {
                let layout;
                layout = xmlData.attrs.layout | 0;
                let attriDef = XMLConfig_1.XMLConfig.getAttrDef(xmlData.tagName, "layout");
                cls = attriDef.cls[layout];
            }
            else
                cls = XMLConfig_1.XMLConfig.tag[xmlData.tagName].cls; //普通组件
        }
        return cls ? cls : defaultCls;
    }
    getFileName(descXMLdata) {
        let attrs = descXMLdata.attrs;
        return attrs.path.substr(1) + attrs.name;
    }
}
exports.Util = Util;


/***/ }),

/***/ "./src/xmlUIParse/DOMParser.ts":
/*!*************************************!*\
  !*** ./src/xmlUIParse/DOMParser.ts ***!
  \*************************************/
/***/ ((__unused_webpack_module, exports) => {


Object.defineProperty(exports, "__esModule", ({ value: true }));
exports.DOMParser = void 0;
class DOMParser {
    index = 0;
    xml;
    constructor() {
    }
    parseFromString(xml) {
        this.xml = `<document>` + xml.replace(/<\?xml.*?\?>\s*/s, '')
            .replace(/\n\s+/g, ' ') // 标准化空白字符
            .trim() + `</document>`;
        return this.parseNode();
    }
    parseNode() {
        this.consume('<');
        const tagName = this.parseTagName();
        const attributes = this.parseAttributes();
        const node = { nodeName: tagName, children: [], attributes: [] };
        if (attributes.length > 0) {
            node.attributes = attributes;
        }
        // 处理自闭合标签
        if (this.peek() === '/') {
            this.consume('/');
            this.consume('>');
            return node;
        }
        this.consume('>');
        node.children = this.parseChildren(tagName);
        return node;
    }
    parseTagName() {
        let tagName = '';
        while (/[^\s/>]/.test(this.peek())) {
            tagName += this.xml[this.index++];
        }
        return tagName;
    }
    parseAttributes() {
        const attributes = [];
        while (this.peek() !== '>' && this.peek() !== '/') {
            this.consumeWhitespace();
            const localName = this.parseAttributeKey();
            this.consume('=');
            const value = this.parseAttributeValue();
            attributes[attributes.length] = { localName: localName, value: value };
        }
        return attributes;
    }
    parseAttributeKey() {
        let key = '';
        while (/[^\s=]/.test(this.peek())) {
            key += this.xml[this.index++];
        }
        return key;
    }
    parseAttributeValue() {
        const quote = this.consume();
        let value = '';
        while (this.peek() !== quote) {
            value += this.xml[this.index++];
        }
        this.consume(quote);
        return value;
    }
    parseChildren(parentTag) {
        const children = [];
        while (true) {
            this.consumeWhitespace();
            // 增强结束标签检测
            if (this.checkClosingTag(parentTag)) {
                break;
            }
            if (this.peek() === '<') {
                children.push(this.parseNode());
            }
            else {
                // 跳过文本内容（可选保留逻辑）
                this.index++;
            }
        }
        return children;
    }
    checkClosingTag(parentTag) {
        if (this.peek() === '<' && this.xml[this.index + 1] === '/') {
            const closingIndex = this.index;
            this.consume('<');
            this.consume('/');
            this.consumeWhitespace();
            const endTag = this.parseTagName();
            this.consumeWhitespace();
            this.consume('>');
            if (endTag !== parentTag) {
                throw new Error(`标签不匹配: 期待 ${parentTag} 实际 ${endTag}`);
            }
            return true;
        }
        return false;
    }
    consume(char) {
        if (char && this.xml[this.index] !== char) {
            throw new Error(`在位置 ${this.index} 期待 "${char}" 但发现 "${this.xml[this.index]}"`);
        }
        return this.xml[this.index++];
    }
    consumeWhitespace() {
        while (/\s/.test(this.peek())) {
            this.index++;
        }
    }
    peek() {
        return this.xml[this.index] || '';
    }
}
exports.DOMParser = DOMParser;
// let obj=(new DOMParser).parseFromString(`<?xml version="1.0" encoding="utf-8"?>
// <component size="161,161" extention="Button">
//   <Button/>
//   <controller name="button" pages="0,up,1,down,2,over,3,selectedOver"/>
//   <displayList>
//     <image id="n0_gl7v" src="hcice" name="n0" xy="0,0">
//       <relation target="" sidePair="width,height"/>
//     </image>
//   </displayList>
// </component>`);
// App.Alert(JSON.stringify(obj));


/***/ }),

/***/ "./src/xmlUIParse/PropType.ts":
/*!************************************!*\
  !*** ./src/xmlUIParse/PropType.ts ***!
  \************************************/
/***/ ((__unused_webpack_module, exports) => {


Object.defineProperty(exports, "__esModule", ({ value: true }));
exports.PropType = void 0;
class PropType {
    static NUMBER = new PropType(0, "数字", "number");
    static STRING = new PropType(1, "字符串", "string");
    static ARRAY = new PropType(2, "数组", "any[]");
    static OBJECT = new PropType(3, "对象", "any");
    static ARRAY2 = new PropType(4, "二维数组", "any[][]");
    static INT = new PropType(5, "整型", "int");
    static UINT = new PropType(6, "无符号整型", "uint");
    static BOOL = new PropType(7, "布尔类型", "boolean");
    static ARRAY_OBJECT = new PropType(8, "对象数组", "any[]");
    static ARRAY_NUMBER = new PropType(9, "数字数组", "number[]");
    static ARRAY_STRING = new PropType(10, "文本数组", "string[]");
    static typeList = [PropType.NUMBER, PropType.STRING,
        PropType.ARRAY, PropType.OBJECT, PropType.ARRAY2, PropType.INT, PropType.UINT, PropType.BOOL, PropType.ARRAY_OBJECT, PropType.ARRAY_NUMBER, PropType.ARRAY_STRING];
    static getType(id) {
        return PropType.typeList[id];
    }
    // public static readonly ARRAY_PAIR:PropType=new PropType(100,"ly.Pair数组");
    _name;
    _id;
    _key;
    constructor(id, name, key) {
        let s = this;
        s._id = id;
        s._name = name;
        s._key = key;
    }
    typeToStr(val) {
        let s = this;
        let str;
        if (s == PropType.NUMBER)
            return val == null ? "0" : String(val);
        if (s == PropType.INT)
            return String(Math.floor(val));
        if (s == PropType.UINT)
            return String(Math.abs(val));
        if (s == PropType.STRING)
            return val == null ? "" : String(val);
        if (s == PropType.ARRAY || s == PropType.ARRAY_NUMBER || s == PropType.ARRAY_STRING)
            return val ? val.toString() : "";
        if (s == PropType.ARRAY_STRING) {
            val = val ? val.split(",") : [];
            return val;
        }
        if (s == PropType.BOOL)
            return val && val != "0" ? "true" : "false";
        if (s == PropType.ARRAY2) {
            if (val == null)
                return "";
            str = val.toString();
            return str.substr(1, str.length - 2);
        }
        if (s == PropType.OBJECT || s == PropType.ARRAY_OBJECT) {
            if (val.contructor == String)
                return val;
            return JSON.stringify(val);
        }
        return "";
    }
    strToValue(val) {
        let s = this;
        if (s == PropType.NUMBER)
            return Number(val);
        if (s == PropType.INT)
            return val | 0;
        if (s == PropType.UINT)
            return Math.abs(val | 0);
        if (s == PropType.STRING)
            return val == null ? "" : String(val);
        if (s == PropType.BOOL)
            return val === "true" || val == "1" ? true : false;
        if (s == PropType.ARRAY || s == PropType.ARRAY_STRING)
            return val ? val.split(",") : [];
        if (s == PropType.ARRAY_NUMBER) {
            if (val) {
                val = PropType.vectorToNumberArray(val.split(","));
                return val;
            }
            else
                return [];
        }
        if (s == PropType.ARRAY2)
            return s.parse("[" + (val ? val : "") + "]");
        if (s == PropType.OBJECT || s == PropType.ARRAY_OBJECT)
            return s.parse(val);
    }
    parse(val) {
        try {
            return JSON.parse(val);
        }
        catch (e) {
            let s = this;
            return s == PropType.ARRAY2 || s == PropType.ARRAY_OBJECT ? [] : null;
        }
    }
    isArray() {
        let s = this;
        return s == PropType.ARRAY2 || s == PropType.ARRAY_OBJECT || s == PropType.ARRAY;
    }
    isNumber() {
        let s = this;
        return s == PropType.UINT || s == PropType.INT || s == PropType.NUMBER;
    }
    /**数组转成数值数组*/
    static vectorToNumberArray(vec) {
        var i, len;
        var arr = [];
        len = vec.length;
        for (i = 0; i < len; ++i) {
            arr[arr.length] = +vec[i];
        }
        return arr;
    }
}
exports.PropType = PropType;


/***/ }),

/***/ "./src/xmlUIParse/XMLConfig.ts":
/*!*************************************!*\
  !*** ./src/xmlUIParse/XMLConfig.ts ***!
  \*************************************/
/***/ ((__unused_webpack_module, exports, __webpack_require__) => {


Object.defineProperty(exports, "__esModule", ({ value: true }));
exports.XMLConfig = void 0;
const PropType_1 = __webpack_require__(/*! ./PropType */ "./src/xmlUIParse/PropType.ts");
class XMLConfig {
    static getAttrDef(tagName, attrName) {
        if (XMLConfig.attri[tagName])
            return XMLConfig.attri[tagName][attrName];
        return XMLConfig.attri.default[attrName];
    }
    /***属性定义
         * names字段表示属性的别名，注意属性可能是多个字段组合，它的值由分隔符隔开，所以别名是数组
         * type 字段类型
         * enum 字段的值可能是枚举，所以也记录一下枚举值
        */
    static attri = {
        transition_item_type: {
            "XY": { desc: "xy坐标", names: ["x", "y"], type: PropType_1.PropType.ARRAY_NUMBER },
            "Alpha": { desc: "透明度", names: ["alpha"], type: PropType_1.PropType.ARRAY_NUMBER },
            "Size": { desc: "宽高", names: ["width", "height"], type: PropType_1.PropType.ARRAY_NUMBER },
            "Skew": { desc: "倾斜", names: ["skewX", "skewY"], type: PropType_1.PropType.ARRAY_NUMBER },
            "Rotation": { desc: "旋转", names: ["rotation"], type: PropType_1.PropType.ARRAY_NUMBER },
            "Color": { desc: "颜色", names: ["color"], type: PropType_1.PropType.STRING },
            "ColorFilter": { desc: "颜色滤镜", names: ["brightness", "contrast", "saturation", "hue"], type: PropType_1.PropType.ARRAY_NUMBER },
            "Pivot": { desc: "轴心", names: ["anchorOffsetX", "anchorOffsetY"], type: PropType_1.PropType.ARRAY_NUMBER },
            "Sound": { desc: "声音", names: ["sound"], type: PropType_1.PropType.STRING },
            "Visible": { desc: "可见性", names: ["visible"], type: PropType_1.PropType.BOOL },
            "Text": { desc: "文本", names: ["text"], type: PropType_1.PropType.STRING }
        },
        transition: {
            "name": { desc: "动画对象-名称", type: PropType_1.PropType.STRING },
            "autoPlay": { desc: "动画对象-自动播放", type: PropType_1.PropType.BOOL },
            "autoPlayRepeat": { desc: "动画对象-自动重复", type: PropType_1.PropType.NUMBER },
            "autoPlayDelay": { desc: "动画对象-自动延迟", type: PropType_1.PropType.NUMBER },
            "frameRate": { desc: "动画对象-帧率", type: PropType_1.PropType.NUMBER },
        },
        item: {
            "time": { desc: "动画-时间", type: PropType_1.PropType.NUMBER },
            "type": { desc: "动画-类型", type: PropType_1.PropType.STRING, attrDef: "transition_item_type" },
            "target": { desc: "动画-目标", type: PropType_1.PropType.STRING },
            "tween": { desc: "动画-是否缓动", type: PropType_1.PropType.BOOL },
            "startValue": { desc: "动画-起始值", type: PropType_1.PropType.STRING },
            "endValue": { desc: "动画-结束值", type: PropType_1.PropType.STRING },
            "value": { desc: "动画-当前值", type: PropType_1.PropType.STRING },
            "duration": { desc: "动画-总时长", type: PropType_1.PropType.NUMBER },
        },
        default: {
            "name": { desc: "通用-组件实例名称", type: PropType_1.PropType.STRING },
            "xy": { desc: "通用-xy定位坐标", names: ["x", "y"], type: PropType_1.PropType.NUMBER },
            "size": { desc: "通用-宽高大小", names: ["width", "height"], type: PropType_1.PropType.NUMBER },
            "scale": { desc: "通用-缩放", names: ["scaleX", "scaleY"], type: PropType_1.PropType.NUMBER },
            "skew": { desc: "通用-倾斜", names: ["skewX", "skewY"], type: PropType_1.PropType.NUMBER },
            "rotation": { desc: "通用-旋转角度", type: PropType_1.PropType.NUMBER },
            "pivot": { desc: "通用-轴心坐标（相对自身）", names: ["anchorX", "anchorY"], type: PropType_1.PropType.NUMBER },
            "alpha": { desc: "通用-透明度", type: PropType_1.PropType.NUMBER },
            "visible": { desc: "通用-可见性", type: PropType_1.PropType.BOOL },
            "touchable": { desc: "通用-可触摸", names: ["touchabled"], type: PropType_1.PropType.BOOL },
            "grayed": { desc: "通用-变灰", type: PropType_1.PropType.BOOL },
            "fold": { desc: "通用-翻转", enum: ["both", "hz", "vt"], type: PropType_1.PropType.STRING },
            "fileName": { desc: "通用-资源文件名", type: PropType_1.PropType.STRING },
            "margin": { desc: "通用-边距(上,下,左,右)", names: ["paddingTop", "paddingBottom", "paddingLeft", "paddingRight"], type: PropType_1.PropType.NUMBER },
            "tooltips": { desc: "其他-提示文本", names: ["toolTipString"], type: PropType_1.PropType.STRING },
            "defaultItem": { desc: "默认item组件引用", type: PropType_1.PropType.STRING },
            "type": { desc: "图形-类型", type: PropType_1.PropType.STRING, enum: ["rect", "eclipse", "polygon", "regular_polygon"] },
            "lineSize": { desc: "图形-线条粗细", type: PropType_1.PropType.NUMBER },
            "lineColor": { desc: "图形-线条颜色", type: PropType_1.PropType.STRING },
            "fillColor": { desc: "图形-填充颜色", type: PropType_1.PropType.STRING },
            "points": { desc: "图形-描点数组", type: PropType_1.PropType.ARRAY_NUMBER },
            "sides": { desc: "图形-边数", type: PropType_1.PropType.NUMBER },
            "corner": { desc: "图形-圆角大小", type: PropType_1.PropType.NUMBER },
            "sidePair": { desc: "关联-布局", type: PropType_1.PropType.ARRAY, enum: ["left-left", "right-right", "top-top", "bottom-bottom", "center-center", "middle-middle", "width-width", "height-height"] },
            "target": { desc: "关联-目标", type: PropType_1.PropType.STRING },
            "layout": { desc: "列表-布局方向", type: PropType_1.PropType.STRING, enum: ["col", "row", "flow_hz", "flow_vt", "pagination"], cls: ["GYLite.GYListV", "GYLite.GYListH", "GYLite.GYGridV", "GYLite.GYGridH", "GYLite.GYGrid"] },
            "selectionMode": { desc: "列表-选择模式", type: PropType_1.PropType.STRING, enum: ["single", "multiple", "multipleSingleClick", "none"] },
            "scrollBar": { desc: "列表-滚动条显示", names: ["scrollPolicy"], type: PropType_1.PropType.STRING, enum: ["auto", "visible", "hidden"] },
            "scrollBarMargin": { desc: "列表-滚动条定位", type: PropType_1.PropType.ARRAY_NUMBER },
            "autoItemSize": { desc: "列表-item尺寸自适应", type: PropType_1.PropType.BOOL },
            "lineGap": { desc: "列表-行距", type: PropType_1.PropType.NUMBER },
            "colGap": { desc: "列表-列距", type: PropType_1.PropType.NUMBER },
            "scrollBarRes": { desc: "列表-滚动条样式", names: ["scrollerBarV", "scrollerBarH"], type: PropType_1.PropType.STRING },
            "scrollBarFlags": { desc: "列表-标志值([拖拽开关,16,32],[回弹开关,64,128])", type: PropType_1.PropType.ARRAY_NUMBER },
            "reverse": { desc: "进度条-是否反向", type: PropType_1.PropType.BOOL },
            "titleType": { desc: "进度条-标题类型", type: PropType_1.PropType.STRING, enum: ["percent", "valueAndmax", "value", "max"] },
            "wholeNumbers": { desc: "滑块-是否整数输入", type: PropType_1.PropType.BOOL },
            "dropdown": { desc: "comboBox-下拉框组件引用", type: PropType_1.PropType.STRING },
            "path": { desc: "package资源记录-组件的路径", type: PropType_1.PropType.STRING },
            "id": { desc: "package资源记录-组件的唯一id", type: PropType_1.PropType.STRING },
            "scale9grid": { desc: "package资源记录-九宫格值[左,上,右,下],输出[x,y,w,h]", type: PropType_1.PropType.ARRAY },
            "extention": { desc: "package资源记录-扩展组件引用", type: PropType_1.PropType.STRING },
            "src": { desc: "package资源记录-资源src", type: PropType_1.PropType.STRING },
            "pkg": { desc: "package资源记录-资源pkg编码", type: PropType_1.PropType.STRING },
            "exported": { desc: "package资源记录-是否导出", type: PropType_1.PropType.BOOL },
            "text": { desc: "文本-文本内容", type: PropType_1.PropType.STRING },
            "font": { desc: "文本-字体", type: PropType_1.PropType.STRING },
            "color": { desc: "文本-颜色", type: PropType_1.PropType.STRING },
            "fontSize": { desc: "文本-字体大小", names: ["size"], type: PropType_1.PropType.NUMBER },
            "align": { desc: "文本-水平对齐", type: PropType_1.PropType.STRING },
            "singleLine": { desc: "文本-是否多行", names: ["mutiline"], type: PropType_1.PropType.BOOL },
            "bold": { desc: "文本-加粗", type: PropType_1.PropType.BOOL },
            "italic": { desc: "文本-斜体", type: PropType_1.PropType.BOOL },
            "underline": { desc: "文本-下划线", type: PropType_1.PropType.BOOL },
            "leading": { desc: "文本-行距", type: PropType_1.PropType.NUMBER },
            "letterSpace": { desc: "文本-字距", type: PropType_1.PropType.NUMBER },
            "vAlign": { desc: "文本-垂直对齐", names: ["verticalAlign"], type: PropType_1.PropType.STRING },
            "prompt": { desc: "文本-输入框默认文本", type: PropType_1.PropType.STRING },
            "maxLength": { desc: "文本-最大长度", names: ["maxChars"], type: PropType_1.PropType.NUMBER },
            "restrict": { desc: "文本-正则限制", type: PropType_1.PropType.STRING },
            "password": { desc: "文本-文本内容", type: PropType_1.PropType.BOOL },
            "input": { desc: "文本-是否输入", type: PropType_1.PropType.BOOL },
            "strokeColor": { desc: "文本-描边颜色", type: PropType_1.PropType.STRING },
            "strokeSize": { desc: "文本-描边粗细", names: ["stroke"], type: PropType_1.PropType.NUMBER },
            "shadowColor": { desc: "文本-投影颜色", type: PropType_1.PropType.NUMBER },
            "shadowOffset": { desc: "文本-投影偏移", names: ["shadowOffsetX", "shadowOffsetY"], type: PropType_1.PropType.NUMBER },
            "title": { desc: "文本标签-标题", type: PropType_1.PropType.STRING },
            "titleColor": { desc: "文本标签-标题颜色", type: PropType_1.PropType.STRING },
            "titleFontSize": { desc: "文本标签-标题字体大小", type: PropType_1.PropType.NUMBER },
            "mode": { desc: "按钮-模式", type: PropType_1.PropType.STRING, enum: ["button", "Check", "Radio"], cls: ["GYLite.GYButton", "GYLite.GYCheckBox", "GYLite.GYRadioButton"] },
        }
    };
    /**标签信息
     * cls 标签对应的类名，如果是显示对象，可用于创建显示对象
    */
    static tag = {
        "component": { cls: "GYLite.GYUIComponent", display: true },
        "image": { cls: "GYLite.GYScaleSprite", display: true },
        "text": { cls: "GYLite.GYText", display: true },
        "list": { cls: "GYLite.GYListV", display: true },
        "loader": { cls: "GYLite.GYLoadImage", display: true },
        "graph": { cls: "GYLite.GYSprite", display: true },
        "richText": { cls: "GYLite.GYRichText", display: true },
        "relation": {},
        "transition": { cls: "edc.ITransitionDict" },
        "item": {},
        "displayList": {},
        "controller": {},
        "packageDescription": {},
        "resources": {},
        "Label": { cls: "GYLite.GYUIComponent" },
        "ComboBox": { cls: "GYLite.GYComboBox" },
        "Button": { cls: "GYLite.GYButton" },
        "ProgressBar": { cls: "GYLite.GYProgressBar" },
        "Slider": { cls: "GYLite.GYSlider" },
        "ScrollBar": { cls: "GYLite.GYScrollBase", clsEnum: ["GYLite.GYScrollBarV", "GYLite.GYScrollBarH"] },
    };
}
exports.XMLConfig = XMLConfig;


/***/ }),

/***/ "./src/xmlUIParse/XMLParser.ts":
/*!*************************************!*\
  !*** ./src/xmlUIParse/XMLParser.ts ***!
  \*************************************/
/***/ ((__unused_webpack_module, exports, __webpack_require__) => {


Object.defineProperty(exports, "__esModule", ({ value: true }));
exports.XMLParser = void 0;
const DOMParser_1 = __webpack_require__(/*! ./DOMParser */ "./src/xmlUIParse/DOMParser.ts");
const XMLConfig_1 = __webpack_require__(/*! ./XMLConfig */ "./src/xmlUIParse/XMLConfig.ts");
class XMLParser {
    static _intance;
    static getInstance() {
        return this._intance ||= new XMLParser;
    }
    constructor() {
    }
    parse(xmlString, pkgId = null) {
        let s = this;
        if (!xmlString)
            return null;
        let parser = new DOMParser_1.DOMParser;
        let xml = parser.parseFromString(xmlString);
        let node = xml.children[0];
        let uiJSON = s.parseUI(node, pkgId);
        return uiJSON;
    }
    parseUI(node, pkgId = null) {
        let s = this;
        if (!node)
            return null;
        let tagDef = XMLConfig_1.XMLConfig.tag[node.nodeName];
        let attriDef;
        if (!tagDef)
            return null;
        let attris = node.attributes;
        let displayData;
        if (pkgId == null) {
            let len = attris.length;
            while (--len > -1) {
                if (attris[len].localName == "id") {
                    pkgId = attris[len].value;
                    break;
                }
            }
        }
        displayData ||= { tagName: node.nodeName, pkgId: pkgId };
        //获取组件类名        
        displayData.cls = tagDef.cls;
        displayData.attrs = {};
        //获取组件属性
        let i, len, j, len2, k, len3;
        let attrName;
        let value;
        let values;
        let ind;
        len = attris.length;
        for (i = 0; i < len; ++i) {
            attrName = attris[i].localName;
            attriDef = XMLConfig_1.XMLConfig.getAttrDef(displayData.tagName, attrName);
            if (!attriDef)
                continue;
            if (attriDef.names) {
                values = attris[i].value.split(",");
                len2 = attriDef.names.length;
                for (j = 0; j < len2; ++j) {
                    value = attriDef.type.strToValue(values[j]);
                    value = s.enumTrans(attriDef.enum, value);
                    displayData.attrs[attriDef.names[j]] = value;
                }
            }
            else {
                value = attriDef.type.strToValue(attris[i].value);
                value = s.enumTrans(attriDef.enum, value);
                displayData.attrs[attrName] = value;
            }
        }
        //处理子级        
        len = node.children.length;
        if (len > 0) {
            let obj;
            displayData.childs = [];
            for (i = 0; i < len; ++i) {
                obj = s.parseUI(node.children[i], pkgId);
                if (obj)
                    displayData.childs.push(obj);
            }
        }
        //处理tween            
        let tweenAttrDef;
        let valueKeys;
        if (displayData.tagName == "transition" && displayData.childs) {
            valueKeys = ["value", "startValue", "endValue"];
            let item;
            len = displayData.childs.length;
            for (i = 0; i < len; ++i) {
                item = displayData.childs[i];
                tweenAttrDef = XMLConfig_1.XMLConfig.getAttrDef("transition_item_type", item.attrs.type);
                if (tweenAttrDef == null)
                    continue;
                len3 = valueKeys.length;
                for (k = 0; k < len3; ++k) {
                    if (item.attrs[valueKeys[k]] == null)
                        continue;
                    value = item.attrs[valueKeys[k]];
                    value = tweenAttrDef.type.strToValue(value);
                    value = s.enumTrans(tweenAttrDef.enum, value);
                    item.attrs[valueKeys[k]] = value;
                }
            }
        }
        return displayData;
    }
    enumTrans(enumArr, value) {
        let i, len, ind;
        if (enumArr) {
            if (Array.isArray(value)) {
                len = value.length;
                for (i = 0; i < len; ++i) {
                    ind = enumArr.indexOf(value[i]);
                    value[i] = ind;
                }
            }
            else {
                ind = enumArr.indexOf(value);
                value = (ind == -1 ? 0 : ind);
            }
        }
        return value;
    }
    /**根据标签名获取子级标签
     * @param data 标签数据
     * @param tagNames 标签名
     * @param recursion 是否递归子级，默认false
     * @param result 结果数组
    */
    getTags(data, tagNames, recursion = false, result = null) {
        if (result == null)
            result = [];
        let childs = data.childs;
        let i, len;
        let s = this;
        if (childs) {
            len = childs.length;
            for (i = 0; i < len; ++i) {
                if (tagNames.indexOf(childs[i].tagName) > -1)
                    result.push(childs[i]);
                if (recursion) {
                    s.getTags(childs[i], tagNames, recursion, result);
                }
            }
        }
        return result;
    }
}
exports.XMLParser = XMLParser;


/***/ })

/******/ 	});
/************************************************************************/
/******/ 	// The module cache
/******/ 	var __webpack_module_cache__ = {};
/******/ 	
/******/ 	// The require function
/******/ 	function __webpack_require__(moduleId) {
/******/ 		// Check if module is in cache
/******/ 		var cachedModule = __webpack_module_cache__[moduleId];
/******/ 		if (cachedModule !== undefined) {
/******/ 			return cachedModule.exports;
/******/ 		}
/******/ 		// Create a new module (and put it into the cache)
/******/ 		var module = __webpack_module_cache__[moduleId] = {
/******/ 			// no module.id needed
/******/ 			// no module.loaded needed
/******/ 			exports: {}
/******/ 		};
/******/ 	
/******/ 		// Execute the module function
/******/ 		__webpack_modules__[moduleId](module, module.exports, __webpack_require__);
/******/ 	
/******/ 		// Return the exports of the module
/******/ 		return module.exports;
/******/ 	}
/******/ 	
/************************************************************************/
/******/ 	/* webpack/runtime/global */
/******/ 	(() => {
/******/ 		__webpack_require__.g = (function() {
/******/ 			if (typeof globalThis === 'object') return globalThis;
/******/ 			try {
/******/ 				return this || new Function('return this')();
/******/ 			} catch (e) {
/******/ 				if (typeof window === 'object') return window;
/******/ 			}
/******/ 		})();
/******/ 	})();
/******/ 	
/************************************************************************/
var __webpack_exports__ = {};
// This entry needs to be wrapped in an IIFE because it needs to be isolated against other modules in the chunk.
(() => {
var exports = __webpack_exports__;
/*!*********************!*\
  !*** ./src/main.ts ***!
  \*********************/

//FYI: https://github.com/Tencent/puerts/blob/master/doc/unity/manual.md
Object.defineProperty(exports, "__esModule", ({ value: true }));
exports.onPublish = onPublish;
exports.onDestroy = onDestroy;
var FairyEditor = CS.FairyEditor;
const XMLParser_1 = __webpack_require__(/*! ./xmlUIParse/XMLParser */ "./src/xmlUIParse/XMLParser.ts");
const Setting_1 = __webpack_require__(/*! ./Setting */ "./src/Setting.ts");
const Util_1 = __webpack_require__(/*! ./Util */ "./src/Util.ts");
const App = FairyEditor.App;
const fs = CS.System.IO.File;
const director = CS.System.IO.Directory;
const Path = CS.System.IO.Path;
console.log('欢迎使用羔羊引擎之fairgui插件');
const setting = new Setting_1.Setting;
// let onTestPlay = new CS.FairyGUI.EventCallback1((c) => {
//     console.log("test is play");
// });
// App.On(FairyEditor.EditorEvents.TestStart, onTestPlay);
function getAllXML(path, result = null) {
    if (result == null)
        result = [];
    if (director.Exists(path)) //文件夹
     {
        let arr = director.GetFiles(path);
        let i, len;
        len = arr.Length;
        for (i = 0; i < len; ++i) {
            path = arr.get_Item(i);
            if (director.Exists(path))
                getAllXML(path, result);
            else if (path.indexOf(".xml") == path.length - 4)
                result.push(path);
        }
    }
    else if (path.indexOf(".xml") == path.length - 4)
        result.push(path);
    return result;
}
function findPkg(pkg) {
    let len;
    let allPage = App.project.allPackages;
    len = allPage.Count;
    while (--len > -1) {
        let item = allPage.get_Item(len);
        if (item.id == pkg)
            return item;
    }
    return null;
}
/**打包所有包*/
function packAll() {
    let allPage = App.project.allPackages;
    let i, len;
    let layoutTS;
    Util_1.Util.packInit();
    layoutTS = setting.getLayoutTS();
    len = allPage.Count;
    for (i = 0; i < len; ++i) {
        let item = allPage.get_Item(i);
        pack(item, layoutTS);
    }
}
/**打包单个包*/
function pack(pkg, layoutTS = null) {
    let i, len, j, len2, len3;
    let files, nameArr;
    let content, fileName, packageName, displayName, pkgName, referencePkg;
    let packDecsName;
    let xmlData, packageData, displayData;
    let displayList;
    let parser;
    let tsStr;
    nameArr = pkg.basePath.split("\\");
    packageName = nameArr[nameArr.length - 1];
    if (Util_1.Util.packageDict[packageName])
        return;
    console.log("正在发布包...." + pkg.basePath);
    packDecsName = "package.xml";
    pkgName = packageName.split(".")[0];
    parser = XMLParser_1.XMLParser.getInstance();
    files = getAllXML(pkg.basePath);
    files.sort((a, b) => {
        if (a.indexOf("\\" + packDecsName) > -1)
            return -1;
        return 1;
    });
    len = files.length;
    if (len > 0) {
        let pkgId = null;
        let dict = {};
        for (i = 0; i < len; ++i) {
            content = fs.ReadAllText(files[i]);
            nameArr = files[i].split("\\");
            fileName = nameArr[nameArr.length - 1];
            xmlData = dict[fileName] = parser.parse(content, pkgId);
            xmlData.fileName = fileName;
            if (packageData && layoutTS) {
                //引用其他包
                let result = parser.getTags(xmlData, ["displayList"]);
                if (result[0]) {
                    let childs = result[0].childs;
                    len2 = childs.length;
                    while (--len2 > -1) {
                        referencePkg = childs[len2].attrs.pkg;
                        if (referencePkg && Util_1.Util.referencePkgs.indexOf(referencePkg) == -1)
                            Util_1.Util.referencePkgs.push(referencePkg);
                    }
                }
                Util_1.Util.packageDict[pkgId].components.push(xmlData);
            }
            if (i == 0) { //描述文件
                pkgId = xmlData.attrs.id;
                packageData = xmlData;
                //由于package.xml的九宫格描述是[x,y,w,h]，需要转换成[left,top,right,bottom]，遍历处理一下
                len2 = xmlData.childs[0].childs.length;
                for (j = 0; j < len2; ++j) {
                    let descObj = xmlData.childs[0].childs[j];
                    let item = pkg.GetItem(descObj.attrs.id);
                    let scale9gridArr;
                    if (descObj.attrs.scale9grid) {
                        scale9gridArr = descObj.attrs.scale9grid;
                        scale9gridArr[0] = Number(scale9gridArr[0]);
                        scale9gridArr[1] = Number(scale9gridArr[1]);
                        scale9gridArr[2] = item.width - scale9gridArr[0] - scale9gridArr[2];
                        scale9gridArr[3] = item.height - scale9gridArr[1] - scale9gridArr[3];
                        descObj.scale9grid = scale9gridArr.join(",");
                    }
                    if (Number(descObj.attrs.scaleX) != Number(descObj.attrs.scaleX))
                        delete descObj.attrs.scaleX;
                    if (Number(descObj.attrs.scaleY) != Number(descObj.attrs.scaleY))
                        delete descObj.attrs.scaleY;
                }
                Util_1.Util.packageDict[pkgId] = { packageData: xmlData, components: [], pkgId: pkgId, pkgName: packageName };
            }
        }
        //输出配置
        let resultPath;
        resultPath = Path.GetFullPath(packageName + ".json", setting.uiJsonPath);
        fs.WriteAllText(resultPath, JSON.stringify(dict, null, 4));
        console.log("发布配置完成:" + resultPath, Util_1.Util.referencePkgs.length);
        if (Util_1.Util.referencePkgs.length > 0) { //处理引用的包
            pkg = findPkg(Util_1.Util.referencePkgs.pop());
            pack(pkg, layoutTS);
        }
        else { //全部关联包都打包完毕，开始导出代码
            let layoutPath;
            let extentionXMLData;
            let cls;
            //查询所有需要导出代码的节点数据
            for (pkgId in Util_1.Util.packageDict) {
                let obj = Util_1.Util.packageDict[pkgId];
                let xmlDatas = obj.components;
                len = xmlDatas.length;
                for (i = 0; i < len; ++i) {
                    if (Util_1.Util.isExported(xmlDatas[i], obj.packageData))
                        Util_1.Util.exportedList.push(xmlDatas[i], obj);
                }
                layoutPath = Path.GetFullPath(obj.pkgName, setting.layoutPath);
                if (director.Exists(layoutPath))
                    director.Delete(layoutPath, true);
                console.log("开始发布代码...", obj.pkgName);
            }
            len = Util_1.Util.exportedList.length;
            for (i = 0; i < len; i += 2) {
                xmlData = Util_1.Util.exportedList[i];
                fileName = xmlData.fileName;
                packageData = Util_1.Util.exportedList[i + 1].packageData;
                pkgName = Util_1.Util.exportedList[i + 1].pkgName;
                tsStr = layoutTS;
                displayList = parser.getTags(xmlData, ["displayList"]);
                //先处理当前文件的关键字替换
                displayName = fileName.split(".")[0];
                tsStr = tsStr.replace(/\{MODULE\}/g, setting.projName + "." + pkgName);
                tsStr = tsStr.replace(/\{PACKAGE\}/g, pkgName);
                tsStr = tsStr.replace(/\{COMPONENT\}/g, displayName);
                if (displayList[0]) {
                    //再处理文件显示列表的属性替换
                    displayList = displayList[0].childs;
                    len2 = displayList.length;
                    for (j = 0; j < len2; ++j) {
                        displayData = displayList[j];
                        extentionXMLData = dict[displayData.attrs.fileName];
                        let obj = Util_1.Util.findDescObj(displayData); //存在外部引用，获取外部包名
                        cls = Util_1.Util.getDefClass(displayData, extentionXMLData, parser, packageData, obj ? obj.pkgName : pkgName, setting.defaultCls);
                        displayData.cls = cls;
                        tsStr = tsStr.replace(/\{PROPERTY\}/g, `{PROPERTY}\n\t\t${displayData.attrs.name}?:${cls};`);
                    }
                    tsStr = tsStr.replace(/\/\/\{PROPERTY\}/g, "");
                    //输出布局文件                    
                    layoutPath = Path.GetFullPath(pkgName, setting.layoutPath);
                    if (!director.Exists(layoutPath))
                        director.CreateDirectory(layoutPath);
                    let layoutFilePath = Path.GetFullPath(displayName + "Layout.ts", layoutPath);
                    fs.WriteAllText(layoutFilePath, tsStr);
                    console.log(layoutFilePath + "代码生成成功!");
                }
            }
        }
    }
}
let menu = App.menu.GetSubMenu("tool");
menu.AddItem("羔羊发布所有包", "GYPublish", (name) => {
    packAll();
    // let arr:CS.System.Collections.Generic.List$1<FairyEditor.FObject> = <CS.System.Collections.Generic.List$1<FairyEditor.FObject>>App.activeDoc.GetSelection();
    // let len:number = arr.Count;    
    // while(--len>-1)
    // {
    //     let obj:FairyEditor.FObject = arr.get_Item(len);
    //     if(obj.objectType == "inputtext")
    //     {   
    //         let txt:FairyEditor.FTextInput = (<FairyEditor.FTextInput>obj);
    //         console.log(txt.name, txt._rawHeight, txt.height, txt.initHeight, txt._sizePercentInGroup);
    //     }        
    // }
    App.Alert("发布所有包完成!");
    // console.log("发布所有包完成!");
});
menu.AddItem("羔羊发布当前包", "GYPublishCur", (name) => {
    let pkgName = App.GetActiveFolder().name;
    let pck = App.project.GetPackageByName(pkgName);
    if (pck) {
        Util_1.Util.packInit();
        pack(pck, setting.getLayoutTS());
        // console.log(pkgName + "-发布完成!");
        App.Alert(pkgName + "-发布完成!");
    }
    else {
        // console.error("找不到包:" + pkgName);        
        App.Alert("找不到包:" + pkgName);
    }
});
function onDestroy() {
    menu.RemoveItem("GYPublish");
    menu.RemoveItem("GYPublishCur");
    console.warn("onDestroy");
}
function onPublish() {
    console.warn("onPublish");
}
__webpack_require__.g.onPublish = onPublish;
__webpack_require__.g.onDestroy = onDestroy;

})();

/******/ })()
;
//# sourceMappingURL=main.js.map      
      Object.defineProperty(exports, "__esModule", { value: true });
      exports.onPublish = onPublish;
      exports.onDestroy = onDestroy;